from src import *
from multiprocessing import Process

if  __name__ == '__main__':
    try:
        p1 = threading.Thread(name="IOC进程",target=IOC_main, daemon=True)
        p1.start()
    except Exception as e:
        print("IOC 进程启动失败:",e)
    try:
        p2 = threading.Thread(name="状态监测线程",target=Monitor_main, daemon=True)
        p2.start()
    except Exception as e:
        print("状态监测进程启动失败",e)
    try:
        p3 = threading.Thread(name="Node状态监测线程",target=Node_Monitor_main, daemon=True)
        p3.start()
    except Exception as e:
        print("状态监测进程启动失败",e)
    try:
        p4 = threading.Thread(name="UDP单播监听线程",target=Unicast_group, daemon=True)
        p4.start()
    except Exception as e:
        print("状态监测进程启动失败",e)
    try:
        p5 = threading.Thread(name="UDP组播监听线程",target=Multicast_group, daemon=True)
        p5.start()
    except Exception as e:
        print("状态监测进程启动失败",e)
    try:
        p6 = threading.Thread(name="UDP心跳监听线程",target=heartbeat_monitor, daemon=True)
        p6.start()
    except Exception as e:
        print("状态监测进程启动失败",e)
    # 保持主线程运行
    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        print("\n系统关闭中...")